package com.gaoding.qa.auto.api;

import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.GetRequest;
import com.dtflys.forest.annotation.PostRequest;
import com.dtflys.forest.annotation.Var;
import com.gaoding.qa.auto.base.BaseGenerateTokenRequestDTO;
import com.gaoding.qa.auto.base.BaseTokenDTO;
import com.gaoding.qa.auto.base.MultiOrgTokenDTO;
import com.gaoding.qa.auto.base.MultiOrgTokenRequestDTO;
import com.gaoding.qa.auto.base.OrgInfoRespDTO;
import com.gaoding.qa.auto.base.UserInfoRespDTO;


/**
 * 通用登陆api
 *
 * @author mobai
 * @since 2021/9/25 18:13
 */
@BaseRequest(baseURL = "${token_generate_domain}")
public interface CommonApi {

    /**
     * 获取登陆token
     *
     * @param generateTokenRequestDTO 入参
     * @return token response
     */
    @PostRequest(value = "/api/oauth/token/v2", headers = {"Content-Type: application/x-www-form-urlencoded"})
    BaseTokenDTO token(@Body BaseGenerateTokenRequestDTO generateTokenRequestDTO);

    /**
     * 获取多租户token
     *
     * @param requestDTO 入参
     * @return token response
     */
    @PostRequest(value = "/api/oauth/token/v2/org-select", headers = {"Content-Type: application/x-www-form-urlencoded"})
    MultiOrgTokenDTO multi(@Body MultiOrgTokenRequestDTO requestDTO);

    /**
     * 获取当前用户身份信息
     *
     * @param token token
     * @return 用户身份
     */
    @GetRequest(value = "/api/ems/users/current", headers = {"authorization:Bearer ${token}"})
    UserInfoRespDTO getUser(@Var("token") String token);


    /**
     * 获取租户信息
     *
     * @param token token
     * @return 租户信息
     */
    @GetRequest(value = "/api/ems/companies/current", headers = {"authorization:Bearer ${token}"})
    OrgInfoRespDTO getOrg(@Var("token") String token);

}
